﻿exports.findInFiles = findInFiles;
exports.addToIndex = addToIndex;

var file = require("file");
var pref = require("pref");

function findInFiles(text, path, lang)
{
    var folder = path;
    var output = file.getTempFile(pref.getOutputFileName());
    var searcher = file.getFif();

    var args = [
        "--text='" + text + "'",
        "--path='" + folder + "'",
        "--file='" + output + "'",
        "--lang='" + lang + "'"
    ];

    searcher.runw(true, args, args.length);
    return output;
}

function addToIndex(path)
{
    if (!path)
    {
        return;
    }

    var indexer = file.getFif();
    var args = [
        "--idx='" + path + "'"
    ];

    indexer.runw(false, args, args.length);
}